<%@ page import="org.springside.core.Constants,cn.firstsoft.modules.portlet.PortletNewConstants,org.springside.modules.security.domain.UserSession"%>
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<%
String path = request.getContextPath();
String imageDownPath=path+"/fileDownload.do?type=Image&path=";
%>

<TABLE id="picImgs" border=0 cellSpacing=0 cellPadding=0 width="100%"   style="background:#FFFFFF">

<c:choose>
	<c:when test="${empty pictureNews}">
		<tr height="82"><td colspan="2"></td></tr>
	</c:when>
	<c:otherwise>
		<c:forEach items="${pictureNews}" var="pictureNews" varStatus="index" >
			  <TR id="picImg_${index.index}" style="display: ${index.index==0?'block':'none'}" >
				<TD width="200px" height="160px"  align="center" style="border: 1px solid #999999;" >
					<A href="javascript:shownews('${pictureNews.id}');" onmouseout="p_timer=setInterval('shownext()',5000);" onmouseover="window.clearInterval(p_timer);">
					<IMG border=0 id="test_${index.index}" onload="resizeImg(this,200,155);"  src="<%=imageDownPath%>/news/
					<fmt:formatDate value="${pictureNews.createdate==null?'':pictureNews.createdate}" pattern="yyyy-MM" />
					/${pictureNews.id}/img/${pictureNews.newsImgName}" style="height:155px">
					</A>			
				</TD>
				<td width="20px">&nbsp;&nbsp;&nbsp;</td>
				<TD class=news_focus vAlign=top >
				    <table>
				    <tr>
				    <td valign="top">
					<SPAN class=news_title_first style="float:left;cursor:pointer;font-size:13px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;vertical-align:middle;" onclick="shownews('${pictureNews.id}');">
					${pictureNews.title}
					</SPAN>
					<c:if test="${pictureNews.isRead==false}">
					<div style="position:relative;top:-20;float:right"><img src='../../themes/portlet/common/new.gif' /></div>
					</c:if>
					</td>			
				    </tr>
				    <tr>
				    <td>
				      <div style="text-indent:2em;line-height:2em;overflow:hidden;text-overflow:ellipsis;height:114px;" >${pictureNews.newsContent}</div>
				    </td> </tr>
				    </table>
				</TD>
			</TR>
		</c:forEach>
	</c:otherwise>
</c:choose>

<TR id="test">
<TD vAlign="bottom" align=middle  >
<c:forEach items="${pictureNews}" var="pictureNews" varStatus="index" >
<c:if test="${index.index==0}" >
<IMG id="dot_${index.index}" src="../../themes/mskin/skin/${sessionScope.loginUser.themePath}/images/news_dot.png" onclick="showImg(${index.index})"  style="cursor:pointer">
</c:if>
<c:if test="${index.index!=0}" >
<IMG id="dot_${index.index}"  src="../../themes/${sessionScope.loginUser.theme}/images/news_graydot.png" onclick="showImg(${index.index})" style="cursor:pointer">
</c:if>
</c:forEach>
</TD>
<td colspan="2" align="right"  vAlign=bottom >
          	<c:if test="${tab.hasMore==1}">
          		<%
          			UserSession userSession = (UserSession) session.getAttribute("loginUser");
          			String color = PortletNewConstants.getMoreColor(userSession.getThemePath());
          		%>
	          <a href="javascript:void(0);" style="color:<%=color %>" onClick='mainJump("/modules/news/news.do?method=showIndex","<%=Constants.USER_THEME_FRAME %>")'
	         	title="<fmt:message key="common_more" />">
	         	
	         	<img src='../../themes/mskin/skin/${sessionScope.loginUser.themePath}/images/more.png' border='0' width='12' height='12' align='middle'/>
	         	<fmt:message key="common_more" /></a>
	         
	         </c:if>

</td>
</TR>
</TABLE>

<script><!--
var openMethod = "${param.openMethod}";
function shownews(id){
	if(openMethod == "_blank"){
		openwinCanResize('<c:url value="/modules/news/news.do?method=show&id="/>'+id,100,50,800,600,'yes');
	}else{
		mainJump("/modules/news/news.do?method=show&id="+id);
	}
}
var currentImg=0;
function showImg(index){
window.clearInterval(p_timer);
imgShow(index);
p_timer=setInterval("shownext()",5000);
}

function imgShow(index){
jQuery("#picImg_"+currentImg).hide();
jQuery("#picImg_"+index).show();
jQuery("#dot_"+currentImg).attr("src","../../themes/mskin/skin/${sessionScope.loginUser.themePath}/images/news_graydot.png");
jQuery("#dot_"+index).attr("src","../../themes/mskin/skin/${sessionScope.loginUser.themePath}/images/news_dot.png");
currentImg=index;
//resizeImgs(jQuery("#test_"+currentImg),200,140);

}
var imgslength='${fn:length(pictureNews)}';
function shownext()
{
  var next=currentImg*1+1;
  if(next==imgslength)
  {
    next=0;
  }
  imgShow(next)
}
var p_timer=setInterval("shownext()",5000);
//直接取宽度可能会取不到




var reset_timer=setInterval("reset()",100);
function reset(){
  var bodyWidth=document.body.clientWidth;
  if(bodyWidth>0)
  {
  jQuery("#picImgs .news_title_first").css("width",bodyWidth-240);
  jQuery("#picImgs .news_flag").css("left",bodyWidth-220);
  window.clearInterval(reset_timer);
  }

}
</script>